package com.rollway.restful.options;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RestfulOptions {

    /**
     * 服务名
     */
    private String serviceName;

    private String scheme;

    private String authority;

    /**
     * 前缀
     */
    private String prefix;

    /*-----------------------------------*/

    /**
     * 方法唯一标识
     */
    private String methodKey;

    private String path;

    private Options options;

    public RestfulOptions copy() {
        RestfulOptions other = new RestfulOptions();
        other.setServiceName(this.getServiceName());
        other.setScheme(this.getScheme());
        other.setAuthority(this.authority);
        other.setPrefix(this.prefix);
        return other;
    }

    public Options getOrInitOptions(){
        if(options == null){
            options = new Options();
        }
        return options;
    }



    @Data
    public static class Options {
        public Options() {
        }

        public Options(Integer connectTimeout, Integer readTimeout) {
            this.connectTimeout = connectTimeout;
            this.readTimeout = readTimeout;
        }

        /**
         * TimeUnit.MILLISECONDS
         */
        private Integer connectTimeout;

        private Integer readTimeout;

        private Integer maxAttempts;

        private Integer maxAttemptTimeMillis;

    }
}
